home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Framework / Includes / UDialogBehavior.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  3.6 KB  |  98 lines  |  [TEXT/MPS ]

  1. // UDialogBehavior.h
  2. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4. #ifndef __UDIALOGBEHAVIOR__
  5. #define __UDIALOGBEHAVIOR__
  6.  
  7. // MacApp
  8.  
  9. #ifndef __UBEHAVIOR__
  10. #include "UBehavior.h"
  11. #endif
  12.  
  13. const IDType kDialogBehavior = 'dlog';        // id of dialog behaviors
  14. const IDType kStdDialogBehavior = 'dlgb';    // class id of dialog behaviors
  15.  
  16. //----------------------------------------------------------------------------------------
  17. // TDialogBehavior
  18. // 
  19. // When installed in a window, this behavior handles events appropriately for both modal
  20. // and modeless dialogs. One subview can be designated the "default item" (eg. OK button)
  21. // and another the "cancel item" (eg. Cancel button in a modal dialog). Pressing the OK
  22. // button in a modal dialog causes the window to be validated. This behavior also treats the 
  23. // pressing of the Enter and Return keys as a click in the default item, and Esc and 
  24. // Command-Period as a click in the cancel item. 
  25. //
  26. // TWindow.PoseModally calls this behavior's PoseModally method to place the window in
  27. // a modal state.
  28. //----------------------------------------------------------------------------------------
  29.  
  30. class TDialogBehavior : public TBehavior
  31. {
  32.     MA_DECLARE_CLASS;
  33.     
  34. public:
  35.     //------------------------------------------------------------------------------------
  36.     // Initializer and I<Method>.
  37.     //------------------------------------------------------------------------------------
  38.  
  39.     TDialogBehavior();
  40.         // Constructor
  41.     virtual ~TDialogBehavior();
  42.         // Destructor
  43.                 
  44.     void IDialogBehavior(Boolean isModal,
  45.                                         IDType  itsDefaultItem,
  46.                                         IDType  itsCancelItem);
  47.         // Initialize this behavior procedurally.
  48.  
  49.     //------------------------------------------------------------------------------------
  50.     // Stream I/O protocol support.
  51.     //------------------------------------------------------------------------------------
  52.  
  53.     virtual void ReadFrom(TStream* aStream);
  54.  
  55.     virtual void WriteTo(TStream* aStream);
  56.  
  57.     //------------------------------------------------------------------------------------
  58.     // Event handling.
  59.     //------------------------------------------------------------------------------------
  60.  
  61.     virtual void Dismiss(IDType dismisser, Boolean validate);
  62.         // Dismiss the owning view (window), validating if requested.
  63.         
  64.     virtual void DoEvent(EventNumber eventNumber,
  65.                                 TEventHandler* source,
  66.                                 TEvent* event);    // Override
  67.         // Handles the mDefaultKey and mCancelKey events. Translates events from
  68.         // the default and cancel items into these events.
  69.         
  70.     virtual void DoKeyEvent(TToolboxEvent* event);    // Override
  71.         // Handles the Enter and Return keys.
  72.         
  73.     virtual void DoCommandKeyEvent(TToolboxEvent* event); // Override
  74.         // Handles the Esc key and Command-Period.
  75.         
  76.     virtual void PoseModally();
  77.         // Places the window owning this behavior in a modal state.
  78.         // Processes events until fDismissed is true.
  79.     
  80.     virtual IDType GetStandardSignature();    // Override 
  81.         // Returns this class's standard signature.
  82.  
  83.     //------------------------------------------------------------------------------------
  84.     // data members
  85.     //------------------------------------------------------------------------------------
  86. public:
  87.     IDType    fDefaultItem;    // The identifier of the view designated as default item
  88.     IDType    fCancelItem;    // The identifier of the view designated as cancel item
  89.                             // Usually the cancel button in a modal dialog, and 
  90.                             // kNoIdentifier for a modeless dialog.
  91.     IDType     fDismisser;        // The identifier of the item which dismissed a modal dialog
  92.     Boolean fModal;            // True if modal behavior is required    
  93.     Boolean fDismissed;        // Becomes true when a modal dialog is dismissed.
  94.  
  95. };
  96.  
  97. #endif
  98.